from django.db import models

from product.models import Product
from utils.models import BaseModel


class Warehouse(BaseModel):
    STOCKSTATUS = (
        (1, "入库"),
        (2, "出库"),
        (3, "报废"),
    )
    product = models.ForeignKey(Product, verbose_name="产品信息", on_delete=models.DO_NOTHING, help_text="产品信息")
    price = models.DecimalField('成本单价', max_digits=10, decimal_places=2, default=0, help_text='成本单价')
    date_of_manufacture = models.DateTimeField("生产日期", help_text="生产日期")
    quality_guarantee = models.IntegerField("保质期天数", help_text="保质期天数")
    num = models.IntegerField("数量", default=0, help_text="数量")
    stock_status = models.CharField("库存状态", max_length=2, choices=STOCKSTATUS, default=1,
                                    help_text='库存状态:1-入库,2-出库,3-报废')
    order_id = models.CharField("订单号", max_length=200, null=True, blank=True, default='', help_text='订单号')
    supplier = models.CharField("供应商", max_length=200, null=True, blank=True, default='', help_text='供应商')
    desc = models.CharField('备注', max_length=1000, null=True, blank=True, default='', help_text='备注')

    class Meta:
        db_table = 'tb_warehouse'
        verbose_name = '库存信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.id
